#!/usr/bin/python
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import smtplib

sender = 'sinosu@163.com'
receiver = '595095286@qq.com'

message = """From: From Person <from@fromdomain.com>
To: To Person <to@todomain.com>
Subject: SMTP e-mail test

This is a test e-mail message.
"""

try:
   smtpObj = smtplib.SMTP('smtp.163.com',25)
   smtpObj.starttls()
   smtpObj.login(sender, "Lovejie8")

   msg = MIMEMultipart()

   msg['From']=sender
   msg['To']=receiver
   msg['Subject']="This is TEST"

   msg.attach(MIMEText(message, 'plain'))

   smtpObj.send_message(msg)         
   print("Successfully sent email")

except smtplib.SMTPException:
   print("Error: unable to send email")
